// 1. 给对象添加类型
type Person = {
  name: string
  age: number
  isSinger: boolean
}

const p1: Person = {
  name: '张三',
  age: 18,
  isSinger: false,
}

const p2: Person = {
  name: '李四',
  age: 28,
  isSinger: true,
}

// 2.  type + 交叉类型模拟继承
type CarBase = {
  width: number
  height: number
  weight: number
}

type Su7 = CarBase & {
  name: string
}

const su7: Su7 = {
  name: '小米su7',
  width: 3,
  height: 3,
  weight: 3,
}

// 3. 思考题
type Res = {
  code: number
  msg: string
  data: {
    title: string
    content: string
  }
}

const res: Res = {
  code: 200,
  msg: 'success',
  data: {
    title: '666',
    content: '666777888',
  },
}

// 4. type和interface的区别
// 非常适合底层封装
interface Dog {
  name: string
}

interface Dog {
  age: number
}

const dog: Dog = {
  name: '旺财',
  age: 18,
}

// type Cat = {
//   name: string
// }

// type Cat = {
//   age: number
// }

export { p1, p2, su7, res, dog }
